/* GUI CONVERTED from rsrp07b.p (converter v1.75) Thu Aug 17 13:39:42 2000 */
/* rsrp07b.p - Release Management Supplier Schedules                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* WEB TAG Insert in rsrp07b.p (converter v1.00) Mon Jul 14 17:25:39 1997 */
/*F0PN*/ /*K0MT*/
/*V8:ConvertMode=Report                                               */
/* REVISION: 7.3    LAST MODIFIED: 10/06/92   BY: WUG *G462*          */
/* REVISION: 7.3    LAST MODIFIED: 07/14/93   BY: WUG *GD42*          */
/* REVISION: 7.3    LAST MODIFIED: 04/08/94   BY: WUG *GJ29*          */
/* REVISION: 8.6E   LAST MODIFIED: 10/09/97   BY: GYK *K0MT*          */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane    */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1    LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1    LAST MODIFIED: 07/27/00   BY: *N0GV* Rajinder Kamra*/

/* SHIPPING SUMMARY REPORT SUBPROGRAM */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdeclre.i}
/*N0GV*/ {gplabel.i}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rsrp07b_p_1 "Sort Option"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsrp07b_p_5 "Start Date"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsrp07b_p_14 "Per Column"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsrp07b_p_15 "Day/Week/Month"
/* MaxLen: Comment: */

/*N0GV
 * &SCOPED-DEFINE rsrp07b_p_2 "Release ID:"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_3 "UM:"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_4 "Ship-To Site:"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_6 "Supplier:"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_7 "Workdays"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_8 "3 - By PO, Item"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_9 "Past    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_10 "Item:"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_11 "2 - By Item, Ship-to, Supplier, PO"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_12 "Net Qty Due"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_13 "Cum Qty Due"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_16 "Purchase Order:"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsrp07b_p_17 "1 - By Ship-to, Supplier, Item, PO"
 * /* MaxLen: Comment: */
 *N0GV*/

/* ********** End Translatable Strings Definitions ********* */

/*K0MT*/ {wbrp02.i}
/*K0MT*
def shared var supplier_from like po_vend.
def shared var supplier_to like po_vend.
def shared var shipto_from like po_ship.
def shared var shipto_to like po_ship.
def shared var part_from like pod_part.
def shared var part_to like pod_part.
def shared var po_from like po_nbr.
def shared var po_to like po_nbr.
def shared var buyer_from like po_buyer.
def shared var buyer_to like po_buyer.
def shared var sortoption as int label "Sort Option" format "9" init 1.
def shared var sortextoption as char extent 3 format "x(34)"
    init [
    "1 - By Ship-to, Supplier, Item, PO",
    "2 - By Item, Ship-to, Supplier, PO",
    "3 - By PO, Item"].

def shared var start as date label "Start Date".
def shared var sdate as date extent 14.
def shared var interval as integer extent 14.
def shared var dwm as char format "x(1)" label "Day/Week/Month".
def shared var idays as int format ">9" label "Per Column".

def var monthend as int.
def shared var num_intervals as int init 13.
def var i as int.


def var net_req as dec.
def var cum_net_req as dec.
def var prior_cum_net_req as dec.
def var cum_net_req_bucket as dec format ">>>>>>>9" extent 13.  /*GJ29*/
def var net_req_bucket as dec format ">>>>>>>9" extent 13.      /*GJ29*/
def var nonwdays as int.
def var workdays as int extent 14 format "->>>,>>9".
def var overlap as int.
*K0MT*/

/*K0MT*/ define shared variable supplier_from like po_vend.
/*K0MT*/ define shared variable supplier_to like po_vend.
/*K0MT*/ define shared variable shipto_from like po_ship.
/*K0MT*/ define shared variable shipto_to like po_ship.
/*K0MT*/ define shared variable part_from like pod_part.
/*K0MT*/ define shared variable part_to like pod_part.
/*K0MT*/ define shared variable po_from like po_nbr.
/*K0MT*/ define shared variable po_to like po_nbr.
/*K0MT*/ define shared variable buyer_from like po_buyer.
/*K0MT*/ define shared variable buyer_to like po_buyer.
/*K0MT*/ define shared variable sortoption as integer label {&rsrp07b_p_1} format
                                                                 "9" init 1.
/*K0MT*/ define shared variable sortextoption as character
                             extent 3 format "x(34)"
/*N0GV*/ .

/*N0GV init [
 *   {&rsrp07b_p_17},
 *   {&rsrp07b_p_11},
 *   {&rsrp07b_p_8}].
 *N0GV*/


/*K0MT*/ define shared variable start as date label {&rsrp07b_p_5}.
/*K0MT*/ define shared variable sdate as date extent 14.
/*K0MT*/ define shared variable interval as integer extent 14.
/*K0MT*/ define shared variable dwm as character
                                        format "x(1)" label {&rsrp07b_p_15}.
/*K0MT*/ define shared variable idays as integer
                                             format ">9" label {&rsrp07b_p_14}.

/*K0MT*/ define variable monthend as integer.
/*K0MT*/ define shared variable num_intervals as integer init 13.
/*K0MT*/ define variable i as integer.


/*K0MT*/ define variable net_req as decimal.
/*K0MT*/ define variable cum_net_req as decimal.
/*K0MT*/ define variable prior_cum_net_req as decimal.
/*K0MT*/ define variable cum_net_req_bucket as decimal
                                      format ">>>>>>>9" extent 13.  /*GJ29*/
/*K0MT*/ define variable net_req_bucket as dec format ">>>>>>>9" extent 13.
                                                              /*GJ29*/
/*K0MT*/ define variable nonwdays as integer.
/*K0MT*/ define variable workdays as integer extent 14 format "->>>,>>9".
/*K0MT*/ define variable overlap as integer.

/*K0MT*
form with frame heading.  /* SCOPE TO PROGRAM */
*K0MT*/
/*K0MT*/ FORM /*GUI*/  with STREAM-IO /*GUI*/  frame heading width 132.  /* SCOPE TO PROGRAM */

for each po_mstr no-lock
where po_nbr >= po_from and po_nbr <= po_to
and po_vend >= supplier_from and po_vend <= supplier_to
and po_buyer >= buyer_from and po_buyer <= buyer_to,
each pod_det no-lock
where pod_nbr = po_nbr
and pod_sched
and pod_part >= part_from and pod_part <= part_to
and pod_site >= shipto_from and pod_site <= shipto_to
and pod_nbr >= po_from and pod_nbr <= po_to,
each sch_mstr no-lock
where sch_type = 4 and sch_nbr = pod_nbr and sch_line = pod_line
and sch_rlse_id = pod_curr_rlse_id[1]
break by pod_part by pod_site by po_vend by po_nbr:
   if first-of(pod_part) then do:
      find pt_mstr where pt_part = pod_part no-lock.
      /*K0MT*   disp
      *K0MT*/
/*K0MT*/ display
      skip(1)
/*N0GV {&rsrp07b_p_10}*/
/*N0GV*/ getTermLabel("ITEM",5) + ":" format "x(6)"
      pod_part at 7
      space(1)
      pt_desc1
      skip(1) space(14)
/*N0GV {&rsrp07b_p_9}*/
/*N0GV*/ getTermLabel("PAST",8)
      sdate[2 for 12]
      skip space(14)
      sdate[2] - 1
      sdate[3] - 1
      sdate[4] - 1
      sdate[5] - 1
      sdate[6] - 1
      sdate[7] - 1
      sdate[8] - 1
      sdate[9] - 1
      sdate[10] - 1
      sdate[11] - 1
      sdate[12] - 1
      sdate[13] - 1
      sdate[14] - 1
      skip space(14)
      "-------- -------- -------- -------- -------- -------- --------"
      "-------- -------- -------- -------- -------- --------"
      with frame heading page-top width 132 no-box no-attr-space
      no-labels STREAM-IO /*GUI*/ .
   end.

   update net_req_bucket = 0.

   prior_cum_net_req = max(sch_pcr_qty - pod_cum_qty[1],0).

   {rcrp07.i &date=sch_pcs_date &qty=prior_cum_net_req}

   for each schd_det no-lock
   where schd_type = sch_type
   and schd_nbr = sch_nbr
   and schd_line = sch_line
   and schd_rlse_id = sch_rlse_id
   by schd_date by schd_time:
      cum_net_req = max(schd_cum_qty - pod_cum_qty[1],0).
      net_req = cum_net_req - prior_cum_net_req.
      prior_cum_net_req = cum_net_req.
      {rcrp07.i &date=schd_date &qty=net_req}
   end.


   update cum_net_req_bucket = 0.
   cum_net_req = 0.

   do i = 1 to num_intervals:
      cum_net_req = cum_net_req + net_req_bucket[i].
      cum_net_req_bucket[i] = cum_net_req.
   end.

   find ad_mstr where ad_addr = po_vend no-lock no-error.

   workdays = 0.
   interval[1] = ?.
   do i = 2 to num_intervals:
      interval[i - 1] = sdate[i] - sdate[i - 1].
   end.

   {mfcwdays.i pod_site}
   /*K0MT*   disp *K0MT*/
/*K0MT*/ display
/*N0GV{&rsrp07b_p_4}               to 13*/
/*N0GV*/ getTermLabelRtColon("SHIP-TO_SITE",13) format "x(13)"
   space(1)
   pod_site
/*N0GV space(2)*/
/*N0GV*/ space(1)
/*N0GV {&rsrp07b_p_6}*/
/*N0GV*/ getTermLabelRtColon("SUPPLIER",10) format "x(10)"
   space(1)
   po_vend
   space(1)
   ad_name                       when (available ad_mstr)
/*N0GV space(2)*/
/*N0GV*/ space(1)
/*N0GV {&rsrp07b_p_16}*/
/*N0GV*/ getTermLabelRtColon("PURCHASE_ORDER",16) format "x(16)"
   space(1)
   po_nbr
   space(2)                                                                 /*GD42*/
/*N0GV {&rsrp07b_p_3} */                                                    /*GD42*/
/*N0GV*/ getTermLabelRtColon("UNIT_OF_MEASURE",3) format "x(3)"
   space(1)                                                             /*GD42*/
   pod_um                                                               /*GD42*/
/*N0GV space(2)*/
/*N0GV*/ space(1)
/*N0GV {&rsrp07b_p_2}*/
/*N0GV*/ getTermLabelRtColon("RELEASE_ID",12) format "x(12)"
   space(1)
   sch_rlse_id format "x(25)"
   skip
   skip(1)
/*N0GV {&rsrp07b_p_7} */
/*N0GV*/ getTermLabel("WORKDAYS",13) format "x(14)"
/*N0GV  space(6)*/
   "" @ workdays[1]
   workdays[2 for 12]
   skip
/*N0GV {&rsrp07b_p_12}*/
/*N0GV*/ getTermLabel("NET_QTY_DUE",13) format "x(14)"
/*N0GV space(3)*/
   net_req_bucket[1 for 13]
   skip
/*N0GV {&rsrp07b_p_13}*/
/*N0GV*/ getTermLabel("CUM_QTY_DUE",13) format "x(14)"
/*N0GV space(3)*/
   cum_net_req_bucket[1 for 13]
   skip(2)
   with width 132 no-box no-attr-space no-labels STREAM-IO /*GUI*/ .
   
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/


   if last-of(pod_part) then do:
      hide frame heading.
      page.
   end.
end.
/*K0MT*/ {wbrp04.i}
